﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class TimHSX : System.Web.UI.Page
{
    ClassPhim cphim = new ClassPhim();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
                CollectionPager1.PageSize = 8;
                CollectionPager1.DataSource = cphim.Tim_HSX(Request.QueryString["id"]).DefaultView;
                CollectionPager1.BindToControl = DataList1;

                DataList1.DataSource = CollectionPager1.DataSourcePaged;
                DataList1.DataBind();
        }
    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "thue")
        {
            DataTable dtb;
            if (Session["Thue"] == null)
            {
                dtb = new DataTable();
                dtb.Columns.Add("MaCD", typeof(string));
                dtb.Columns.Add("TenCD", typeof(string));
                dtb.Columns.Add("SoLuong", typeof(int));
                dtb.Columns.Add("GiaThue", typeof(float));
                dtb.Columns.Add("ThanhTien", typeof(float), "SoLuong*GiaThue");
                dtb.PrimaryKey = new DataColumn[] { dtb.Columns[0] };
                Session["Thue"] = dtb;
            }
            else
                dtb = (DataTable)Session["Thue"];
            HyperLink Ten = (HyperLink)e.Item.FindControl("hlChiTiet");
            Label Gia = (Label)e.Item.FindControl("lbGia");
            dtb.Rows.Add(e.CommandArgument.ToString(), Ten.Text, 1, Gia.Text);
            Session["Thue"] = dtb;
        }
        else
        {
            Response.Redirect("ChiTietPhim.aspx?idcd=" + e.CommandArgument.ToString());
        }
    }
}
